<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="mvc" uri="http://www.springframework.org/tags/form" %>
<%@taglib prefix="fmt" uri="http://www.springframework.org/tags" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>我的考试</title>
<%--    <link rel="stylesheet" href="/lims/layui/css/layui.css?20190817.1">--%>
    <link rel="stylesheet" href="/lib/layui/layui/css/layui.css?20190817.1">
    <link href="/css/exam/main.css" rel="stylesheet" type="text/css" />
    <link href="/css/exam/iconfont.css" rel="stylesheet" type="text/css" />
    <link href="/css/exam/test.css" rel="stylesheet" type="text/css" />
<%--    <link rel="stylesheet" href="/lims/layui/css/layui.css?20190817.1">--%>
    <style>
        .hasBeenAnswer {
            background: #5d9cec;
            color:#fff;
        }
        .test_main{
            width: 100%;
            display: flex;
            flex-direction: row;
        }
        .nr_left{
            width: 80%;
        }
        .nr_right{
            width: 20%;
        }
        .main{
            width: 90%;
            margin: 0 auto;
        }
        .nr_left {
            width: 72%;
        }
    </style>

</head>
<body>
<div class="main">
    <!--nr start-->
    <div class="test_main">
        <div class="nr_left">
            <div class="test">
                <form action="" method="post">
                    <div class="test_title">
                        <p class="test_time">
                            <i class="layui-icon layui-icon-face-smile-fine layui-icon-log"></i><b class="alt-1"></b>
                        </p>
                        <font><input type="button" name="test_jiaojuan"id="jiaojuan"  value="交卷"></font>
                    </div>

                    <div class="test_content single" id="single">
                        <div class="test_content_title">
                            <h2>单选题</h2>
                            <%--<p>--%>
                            <%--<span>共</span><i class="content_lit">60</i><span>题，</span><span>合计</span><i class="content_fs">60</i><span>分</span>--%>
                            <%--</p>--%>
                        </div>
                    </div>
                    <div class="test_content_nr list1">
                        <ul>

                        </ul>
                    </div>

                    <div class="test_content multiple" id="multiple">
                        <div class="test_content_title">
                            <h2>多选题</h2>
                        </div>
                    </div>
                    <div class="test_content_nr list2">
                        <ul>
                        </ul>
                    </div>

                    <div class="test_content judge" id="judge">
                        <div class="test_content_title">
                            <h2>判断题</h2>
                        </div>
                    </div>
                    <div class="test_content_nr list3">
                        <ul>
                        </ul>
                    </div>

                    <div class="test_content blanks" id="blanks">
                        <div class="test_content_title">
                            <h2>填空题</h2>
                        </div>
                    </div>
                    <div class="test_content_nr list4">
                        <ul>
                        </ul>
                    </div>

                    <div class="test_content objective" id="objective">
                        <div class="test_content_title">
                            <h2>客观题</h2>
                        </div>
                    </div>
                    <div class="test_content_nr list5">
                        <ul>
                        </ul>
                    </div>

                </form>
            </div>

        </div>
        <div class="nr_right">
            <div class="nr_rt_main">
                <div class="rt_nr1">
                    <div class="rt_nr1_title">
                        <h1 style="width: 280px;background: #5d9cec;">
                            <i class="" style="font-size: 18px;font-weight: bold;">总分：</i><b class="grade" style="font-size: 18px;"></b>
                        </h1>
                    </div>
                    <div class="rt_nr1_title">
                        <h1>
                            <i class="icon iconfont"></i>答题卡
                        </h1>
                        <p class="test_time">
                            <i class="icon iconfont type" style="color: #000;font-size: 14px;margin: 2px 0px 0px 30px;"></i>
                        </p>
                    </div>

                    <div class="rt_content single">
                        <div class="rt_content_tt">
                            <h2>单选题</h2>
                        </div>
                        <div class="rt_content_nr answerSheet answer1">
                            <ul>

                                <li><a href="#qu_0_0">1</a></li>


                            </ul>
                        </div>
                    </div>

                    <div class="rt_content multiple">
                        <div class="rt_content_tt">
                            <h2>多选题</h2>
                        </div>
                        <div class="rt_content_nr answerSheet answer2">
                            <ul>

                                <li><a href="#qu_2_0">2</a></li>


                            </ul>
                        </div>
                    </div>

                    <div class="rt_content judge">
                        <div class="rt_content_tt">
                            <h2>判断题</h2>
                        </div>
                        <div class="rt_content_nr answerSheet answer3">
                            <ul>

                                <li><a href="#qu_3_0">1</a></li>


                            </ul>
                        </div>
                    </div>

                    <div class="rt_content blanks">
                        <div class="rt_content_tt">
                            <h2>填空题</h2>
                        </div>
                        <div class="rt_content_nr answerSheet answer4">
                            <ul>

                                <li><a href="#qu_4_0">1</a></li>


                            </ul>
                        </div>
                    </div>

                    <div class="rt_content objective">
                        <div class="rt_content_tt">
                            <h2>客观题</h2>
                            <%--<p>--%>
                            <%--<span>共</span><i class="content_lit">60</i><span>题</span>--%>
                            <%--</p>--%>
                        </div>
                        <div class="rt_content_nr answerSheet answer5">
                            <ul>

                                <li><a href="#qu_5_0">1</a></li>

                            </ul>
                        </div>
                    </div>


                </div>

            </div>
        </div>
    </div>
    <!--nr end-->
    <div class="foot"></div>
</div>

<script type="text/javascript" src="/js/jquery/jquery-1.9.1.js"></script>
<script src="/js/exam/jquery.easy-pie-chart.js"></script>
<!--时间js-->
<script src="/js/exam/jquery.countdown.js?20191203"></script>
<script type="text/javascript" src="/lib/layer/layer.js?20201106"></script>
<script type="text/javascript" src="/js/base/base.js"></script>
<script>

    function GetQueryString(name) {
        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return unescape(r[2]); return null;
    }
    var zmarr=['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R'];
    var zmIndex=0;
    var pId=GetQueryString('pId');
    var uid=GetQueryString('uId');
    var scoreId=GetQueryString('scoreId');
    var oneArr=[];
    var twoArr=[];
    var threeArr=[];
    var fourArr=[];
    var fiveArr=[];
    $(function() {
        var dateNow = parseInt(GetQueryString('dateNow'));
        $.ajax({
            url:'/exaPaper/selectById',
            data:{
                pId:pId,
                type:1
            },
            asycn:false,
            dataType:'json',
            type:'get',
            success:function (res) {
                var data=res.object
                $('.grade').html(data.countScores);
                var eqType=data.eqType
                //难度类型（1-简单 2-中等 3-困难）
                if(eqType==1){
                    $('.type').html('难度类型:简单')
                }else if(eqType==2){
                    $('.type').html('难度类型:中等')
                }else{
                    $('.type').html('难度类型:困难')
                }

                function testTime() {
                    var date = res.object.testTime;
                    var time = date * 60
                    setInterval(function(){
                        countDown(time);
                        time-- ;
                    },1000);
                }
                //单选
                var list1='';
                var answer1='';

                if(res.object.list1!=undefined)
                for(var i=0;i<res.object.list1.length;i++) {
                    var data = res.object.list1;
                    var str=new String();
                    var arr=new Array();
                    str=data[i].option
                    arr=str.split(';');//注split可以用字符或字符串分割
                    list1 += '<li id="qu_0_' + [i] + '"  class="oneUl">' +
                        '<div class="test_content_nr_tt">' +
                        ' <i>' + [i+1] + '</i><span>('+[data[i].score]+'分)</span><font>' + data[i].eqSubject + '（  ）</font>' +
                        ' </div>' +
                        ' <div class="test_content_nr_main">' +
                        ' <ul>' + function(){
                            var str=''
                            zmIndex=0
                            for(var j=0;j<arr.length;j++){
                                if(arr[j]!=''){
                                    str += ' <li class="option">' +
                                        ' <input type="radio" class="radioOrCheck one answer'+[i]+'" score='+data[i].score+' option="'+zmarr[zmIndex]+'"  eqId='+data[i].eqId+' name="0_answer'+[i]+'" id="0_answer_'+[i+1]+'_option_'+j+'"/>' +
                                        ' <label for="0_answer_'+[i+1]+'_option_'+j+'"><p class="ue" style="display: inline;">'+arr[j]+'</p> </label>' +
                                        '</li>'
                                    zmIndex++
                                }
                            }
                            return str;
                        }() +' </ul>' +
                        ' </div>' +
                        '</li>';

                    answer1+='<li><a href="#qu_0_' + [i] + '">'+[i+1]+'</a></li>';
                }
                $('.list1 ul').html(list1)
                $('.answer1 ul').html(answer1)
                if(res.object.list1 = '' || res.object.list1.length <=0){
                    $('#single').hide()
                    $('.single').hide()
                }


                //多选题
                var list2='';
                var answer2='';

                if(res.object.list2!=undefined)
                for(var i=0;i<res.object.list2.length;i++) {
                    var data = res.object.list2;
                    var str=new String();
                    var arr=new Array();
                    str=data[i].option
                    arr=str.split(';');//注split可以用字符或字符串分割
                    list2 += '<li id="qu_1_' + [i] + '" class="twoUl">' +
                        '<div class="test_content_nr_tt">' +
                        ' <i>' + [i+1] + '</i><span>('+[data[i].score]+'分)</span><font>' + data[i].eqSubject + '（  ）</font>' +
                        ' </div>' +
                        ' <div class="test_content_nr_main">' +
                        ' <ul>' +function(){
                            var str=''
                            zmIndex=0
                            for(var j=0;j<arr.length;j++){
                                if(arr[j]!=''){
                                    str += ' <li class="option">' +
                                        ' <input type="checkbox" class="radioOrCheck two answer_1'+[i]+'" score='+data[i].score+' option="'+zmarr[zmIndex]+'"  eqId='+data[i].eqId+' name="2_answer'+[i]+'" id="1_answer_'+[i+1]+'_option_'+j+'"/>' +
                                        ' <label for="1_answer_'+[i+1]+'_option_'+j+'"><p class="ue" style="display: inline;">'+arr[j]+'</p> </label>' +
                                        '</li>'
                                    zmIndex++;
                                }
                            }
                            return str;

                        }()
                        +' </ul>' +
                        ' </div>' +
                        '</li>';
                    answer2+='<li><a href="#qu_1_' + [i] + '">'+[i+1]+'</a></li>';
                }
                $('.list2 ul').html(list2)
                $('.answer2 ul').html(answer2)
                if(res.object.list2 = '' || res.object.list2.length <=0){
                    $('#multiple').hide()
                    $('.multiple').hide()
                }

                //判断
                var list3='';
                var answer3='';

                if(res.object.list3!=undefined)
                for(var i=0;i<res.object.list3.length;i++) {
                    var data = res.object.list3;
                    list3 += '<li id="qu_2_' + [i] + '" class="threeUl">' +
                        '<div class="test_content_nr_tt">' +
                        ' <i>' + [i+1] + '</i><span>('+[data[i].score]+'分)</span><font>' + data[i].eqSubject + '（  ）</font>' +
                        ' </div>' +
                        ' <div class="test_content_nr_main">' +
                        ' <ul>' +
                        ' <li class="option">' +
                        ' <input type="radio" class="radioOrCheck three answer_2'+[i]+'" score='+data[i].score+' option="0"  eqId='+data[i].eqId+' name="3_answer'+[i]+'" id="2_answer_'+[i+1]+'_option_1"/>' +
                        ' <label for="2_answer_'+[i+1]+'_option_1"><p class="ue" style="display: inline;">正确</p> </label>' +
                        '</li>' +
                        '<li class="option">' +
                        '   <input type="radio" class="radioOrCheck three answer_2'+[i]+'" score='+data[i].score+' option="1" eqId='+data[i].eqId+' name="3_answer'+[i]+'" id="2_answer_'+[i+1]+'_option_2"/>' +
                        '   <label for="2_answer_'+[i+1]+'_option_2"><p class="ue" style="display: inline;">错误</p>' +
                        ' </label>' +
                        ' </li>' +
                        ' </ul>' +
                        ' </div>' +
                        '</li>';
                    answer3+='<li><a href="#qu_2_'+[i]+'">'+[i+1]+'</a></li>';
                }
                $('.list3 ul').html(list3);
                $('.answer3 ul').html(answer3)
                if(res.object.list3 = '' || res.object.list3.length <=0){
                    $('#judge').hide()
                    $('.judge').hide()
                }


                //填空题
                var list4='';
                var answer4='';

                if(res.object.list4!=undefined)
                for(var i=0;i<res.object.list4.length;i++) {
                    var data = res.object.list4;
                    list4+='<li id="qu_3_'+[i]+'" class="fourUl">'+
                        '<div class="test_content_nr_tt">'+
                        ' <i>' + [i+1] + '</i><span>('+[data[i].score]+'分)</span><font>' + data[i].eqSubject + ' &emsp;<input type="text" width="100px" class="four answer_3'+[i]+'" style="border: none;border-bottom: 1px solid;" eqId='+data[i].eqId+' score='+data[i].score+' id="3_answer_'+[i+1]+'_option_1"/></font> '+
                        ' </div>'+
                        '</li>';
                    answer4+='<li><a href="#qu_3_'+[i]+'">'+[i+1]+'</a></li>';
                }
                $('.list4 ul').html(list4);
                $('.answer4 ul').html(answer4)
                if(res.object.list4 = '' || res.object.list4.length <=0){
                    $('#blanks').hide()
                    $('.blanks').hide()
                }

                //客观题
                var list5='';
                var answer5='';

                if(res.object.list5!=undefined)
                for(var i=0;i<res.object.list5.length;i++) {
                    var data = res.object.list5;
                    list5+='<li id="qu_4_'+[i]+'"  class="fiveUl">'+
                        '<div class="test_content_nr_tt">'+
                        ' <i>' + [i+1] + '</i><span>('+[data[i].score]+'分)</span><font>' + data[i].eqSubject + '</font><br/>'+
                        '<textarea style="width: 100%;height: 100px" class="five answer_4'+[i]+'" eqId='+data[i].eqId+' score='+data[i].score+' id="4_answer_'+[i+1]+'_option_1" ></textarea>'+
                        ' </div>'+
                        '</li>';
                    answer5+='<li><a href="#qu_4_'+[i]+'">'+[i+1]+'</a></li>';
                }
                $('.list5 ul').html(list5)
                $('.answer5 ul').html(answer5)
                if(res.object.list5 = '' || res.object.list5.length <=0){
                    $('#objective').hide()
                    $('.objective').hide()
                }
                $.ajax({
                    url:'/exaExamination/selectByPid',
                    data:{
                        pid:pId
                    },
                    asycn:false,
                    dataType:'json',
                    type:'get',
                    success:function (ress) {
                        var data = ress.object
                        if(ress.object.scoreId!=undefined){
                            scoreId = ress.object.scoreId;
                        }
                        $(function(){
                            if(ress.object==undefined){
                                testTime()
                            }else{
                                if(ress.object.countDown!=''&&ress.object.countDown!=undefined){
                                    var date = ress.object.countDown;
                                    var time = date * 60
                                    setInterval(function(){
                                        countDown(time);
                                        time-- ;
                                    },1000);
                                }else{
                                    testTime()
                                }
                            }


                        });
                        for (var i = 0; i < ress.object.list1.length; i++) {
                            var data1 = ress.object.list1;
                            var num=''
                            if(data1[i].answer=='A'){
                                num=1
                            }else if(data1[i].answer=='B'){
                                num=2
                            }else if(data1[i].answer=='C'){
                                num=3
                            }else if(data1[i].answer=='D'){
                                num=4
                            }

                            // $('.one[eqId="'+data1[i].exaQuestions.eqId+'"][value="'+data1[i].answer+'"]').attr('checked','checked')
                            $('.one[eqId="'+data1[i].exaQuestions.eqId+'"]').eq(num-1).attr('checked','checked')
                            $('.one[eqId="'+data1[i].exaQuestions.eqId+'"]').eq(num-1).parents('.oneUl').addClass('oneActive')
                            oneArr.push(data1[i].exaQuestions.eqId+'|'+data1[i].answer+'|'+data1[i].scoreNum)

                        }
                        for (var m = 0; m < ress.object.list2.length; m++) {
                            var data = ress.object.list2;
                            var num=''
                           if(data[m].answer!=''&&data[m].answer.indexOf('*')>=0){
                                var tarr = data[m].answer.split('*');
                                for(var j=0;j<tarr.length;j++){
                                    if(tarr[j]!=''){
                                        if(tarr[j]=='A'){
                                            num=1
                                        }else if(tarr[j]=='B'){
                                            num=2
                                        }else if(tarr[j]=='C'){
                                            num=3
                                        }else if(tarr[j]=='D'){
                                            num=4
                                        }
                                        $('.two[eqId="'+data[m].exaQuestions.eqId+'"]').eq(num-1).parents('.twoUl').addClass('twoActive')
                                        $('.two[eqId="'+data[m].exaQuestions.eqId+'"]').eq(num-1).prop('checked','checked')
                                    }
                                }
                               twoArr.push(data[m].exaQuestions.eqId+'|'+data[m].answer+'|'+data[m].scoreNum)

                            }

                        }
                        for (var n = 0; n < ress.object.list3.length; n++) {
                            var data = ress.object.list3;
                            var num=''
                            if(data[n].answer=='正确'){
                                num=0
                            }else if(data[n].answer=='错误') {
                                num = 1
                            }
                            $('.three[eqId="'+data[n].exaQuestions.eqId+'"]').eq(num).parents('.threeUl').addClass('threeActive')
                            threeArr.push(data[n].exaQuestions.eqId+'|'+data[n].answer+'|'+data[n].scoreNum)
                            $('.three[eqId="'+data[n].exaQuestions.eqId+'"]').eq(num).prop('checked','checked')
//                            $('#2_answer_'+[i+1]+'_option_'+num+'').attr('checked','checked')
                        }

                        for (var i = 0; i < ress.object.list4.length; i++) {
                            var data = ress.object.list4;
                            $('.four[eqId="'+data[i].exaQuestions.eqId+'"]').parents('.fourUl').addClass('fourActive')
                            $('.four[eqId="'+data[i].exaQuestions.eqId+'"]').val(data[i].answer)
//                            $('#3_answer_'+[i+1]+'_option_1').val(data[i].answer)
                        }
                        for (var i = 0; i < ress.object.list5.length; i++) {
                            var data = ress.object.list5;
                            $('.five[eqId="'+data[i].exaQuestions.eqId+'"]').parents('.fiveUl').addClass('fiveActive')
                            $('.five[eqId="'+data[i].exaQuestions.eqId+'"]').val(data[i].answer)
//                            $('#4_answer_'+[i+1]+'_option_1').val(data[i].answer)
                        }
                    }
                })


                $('li .option label').click(function() {
                    var examId = $(this).closest('.test_content_nr_main').closest('li').attr('id'); // 得到题目ID
                    var cardLi = $('a[href=#' + examId + ']'); // 根据题目ID找到对应答题卡
                    // 设置已答题
                    if(!cardLi.hasClass('hasBeenAnswer')){
                        cardLi.addClass('hasBeenAnswer');
                    }
                });
                $('.fourUl input').change(function() {
                    var examId = $(this).closest('.fourUl').attr('id')// 得到题目ID
                    var cardLi = $('a[href=#' + examId + ']'); // 根据题目ID找到对应答题卡
                    // 设置已答题
                    if(!cardLi.hasClass('hasBeenAnswer')){
                        cardLi.addClass('hasBeenAnswer');
                    }
                });
                $('.fiveUl textarea').change(function() {
                    var examId = $(this).closest('.fiveUl').attr('id')// 得到题目ID
                    var cardLi = $('a[href=#' + examId + ']'); // 根据题目ID找到对应答题卡
                    // 设置已答题
                    if(!cardLi.hasClass('hasBeenAnswer')){
                        cardLi.addClass('hasBeenAnswer');
                    }
                });

                $('li .option input').click(function() {
                    var examId = $(this).closest('.test_content_nr_main').closest('li').attr('id'); // 得到题目ID
                    var cardLi = $('a[href=#' + examId + ']'); // 根据题目ID找到对应答题卡
                    // 设置已答题
                    if(!cardLi.hasClass('hasBeenAnswer')){
                        cardLi.addClass('hasBeenAnswer');
                    }
                })
                var resSingle=''
                var resFill=''
                var resMore=''
                var resJudge=''
                var resObj=''
                $(".one").click(function () {
                    $(this).parents('.oneUl').addClass('oneActive')
                    oneArr=[]
                    for(var i=0;i<$('.oneActive').length;i++){
                        var obj = $('.oneActive').eq(i).find('input[type="radio"]:checked')
                        var str= obj.attr('eqId')+'|'
                            + obj.attr('option')+'|'+obj.attr('score')
                        oneArr.push(str)
                    }
                    resSingle=''
                    for(var j=0;j<oneArr.length;j++){
                        resSingle += oneArr[j]+'&'
                    }
                    save(resSingle,resFill,resMore,resJudge,resObj)
                })

                $(".two").click(function () {
                    $(this).parents('.twoUl').addClass('twoActive')
                    var eqId = $(this).attr('eqId');
                   var twoArr=[]
                    for(var i=0;i<$('.twoActive').length;i++){
                        var chk_value='';
                        var str=''
                        $('.twoActive').eq(i).find('input[type="checkbox"]:checked').each(function() {//遍历每一个名字为interest的复选框，其中选中的执行函数
                            chk_value+=$(this).attr('option')+'*'
                        })
                        var obj = $('.twoActive').eq(i).find('input[type="checkbox"]:checked')
                        str = obj.attr('eqId')+'|'
                            + chk_value+'|'+obj.attr('score')

                        twoArr.push(str)
                    }
//                    twoArr=twoArr.concat(arr)


                    resMore=''
                    for(var j=0;j<twoArr.length;j++){
                        resMore += twoArr[j]+'&'
                    }
                    // console.log(twoArr)
                    save(resSingle,'',resMore,resJudge,resObj)
                })


                $(".three").click(function () {
                    $(this).parents('.threeUl').addClass('threeActive')
                    var arr=[]
                    for(var i=0;i<$('.threeActive').length;i++){
                        var obj = $('.threeActive').eq(i).find('input[type="radio"]:checked')
                        var str = obj.attr('eqId')+'|'
                            + obj.attr('option')+'|'+obj.attr('score')
                        arr.push(str)
                    }
                    resJudge=''
                    for(var j=0;j<arr.length;j++){
                        resJudge += arr[j]+'&'
                    }
                    save(resSingle,'','',resJudge,resObj)
                })


                $(".four").change(function () {
                    $(this).parents('.fourUl').addClass('fourActive')
                    var arr=[]
                    for(var i=0;i<$('.fourActive').length;i++){
                        var obj = $('.fourActive').eq(i).find('.four')
                        var str = obj.attr('eqId')+'|'
                            + obj.val()+'|'+obj.attr('score')
                        arr.push(str)
                    }
                    resFill=''
                    for(var j=0;j<arr.length;j++){
                        resFill += arr[j]+'&'
                    }
                    save(resSingle,resFill,'','',resObj)
                })


                $(".five").change(function () {
                    $(this).parents('.fiveUl').addClass('fiveActive')
                    var arr=[]
                    for(var i=0;i<$('.fiveActive').length;i++){
                        var obj = $('.fiveActive').eq(i).find('.five')
                        var str = obj.attr('eqId')+'|'
                            + obj.val()+'|'+obj.attr('score')
                        arr.push(str)
                    }
                    resObj=''
                    for(var j=0;j<arr.length;j++){
                        resObj += arr[j]+'&'
                    }
                    save(resSingle,resFill,resMore,resJudge,resObj)
                })


                function  save(resSingle,resFill,resMore,resJudge,resObj) {
                    $.ajax({
                        url:'/exaExamination/insertSheet',
                        data:{
                            pId:pId,
                            resSingle:resSingle,
                            resFill:resFill,
                            resMore:resMore,
                            resJudge:resJudge,
                            resObj:resObj,
                            countDown:$('.minutes').text(),
                            scoreId:scoreId
                        },
                        dataType:'json',
                        type:'post',
                        success:function (res) {
                            if(res.code==0){
                                scoreId = res.object;
                            }
                        }
                    })
                }


            }
        })
    });
    function paper(){
        var resSingle='';
        for(var i=0;i<$('.oneUl').length;i++){
            var answer='.'+'answer'+[i]+''
            if ($(answer).is(":checked")) {
                var chk_value=$(answer +':checked').attr('option')
                resSingle+= $(answer).attr('eqId')+ '|'
                    + chk_value + '|' + $(answer).attr('score')+'&'
            } else {
                resSingle+= $(answer).attr('eqId')+ '||' + $(answer).attr('score')+'&'
            }
        }
        var twoArr=[]
        var resMore=''
        for(var i=0;i<$('.twoActive').length;i++){
            var chk_value='';
            $('.twoActive').eq(i).find('input[type="checkbox"]:checked').each(function() {//遍历每一个名字为interest的复选框，其中选中的执行函数
                chk_value+=$(this).attr('option')+'*'
            })
            var obj = $('.twoActive').eq(i).find('input[type="checkbox"]:checked')
            resMore += obj.attr('eqId')+'|'
                + chk_value+'|'+obj.attr('score')+'&'

        }


        var resJudge='';
        for(var i=0;i<$('.threeUl').length;i++){
            var answer='.'+'answer_2'+[i]+''
            var chk_value=$(answer +':checked').attr('option')
            if(chk_value==undefined){
                chk_value = "";
            }
            resJudge+= $(answer).attr('eqId')+ '|'
                +  chk_value+ '|' + $(answer).attr('score')+'&'
        }

        var resFill='';
        for(var i=0;i<$('.fourUl').length;i++){
            var answer='.'+'answer_3'+[i]+''
            resFill+= $(answer).attr('eqId')+ '|'
                + $(answer).val() + '|' +$(answer).attr('score') +'&'
        }

        var resObj='';
        for(var i=0;i<$('.fiveUl').length;i++){
            var answer='.'+'answer_4'+[i]+''
            resObj+=  $(answer).attr('eqId')+ '|'
                + $(answer).val() + '|' +$(answer).attr('score')+'&'
        }

        $.ajax({
            url:'/exaExamination/reviewPaper',
            data:{
                pId:pId,
                resSingle:resSingle,
                resFill:resFill,
                resMore:resMore,
                resJudge:resJudge,
                resObj:resObj
            },
            dataType:'json',
            type:'post',
            success:function (res) {
                if(res.code ==0){
                    layer.msg('交卷成功', { icon:6,time:3000},function(){
                        window.opener.location.reload();
                        window.close();
                    });

                }
            }
        })
    }
    $('#jiaojuan').click(function(){
        layer.confirm('确认交卷？', {
            btn: ['确定', ' 取消'], //按钮
            title: "交卷"
        }, function(){
            paper()
        }, function(){
            layer.closeAll();
        });
    })



</script>

</body>
</html>
